<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="format-detection" content="telephone=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="icon" href="/blog/blog/images/icons/favicon-16x16.png?v=2.6.2" type="image/png" sizes="16x16"><link rel="icon" href="/blog/blog/images/icons/favicon-32x32.png?v=2.6.2" type="image/png" sizes="32x32"><meta name="description" content=".back-top{position: fixed;top: 500px;height: 0px;float: right;right: 50px;} .back-top&gt;a{font-weight:bold;width: 50px;height: 50px;text-align: center;text-decoration: none;font-size: 5px;line-height:">
<meta property="og:type" content="article">
<meta property="og:title" content="SpringMVC学习笔记(所有代码FROM SIKI学院)">
<meta property="og:url" content="https://bruce-jj.gitee.io/blog/2021/03/17/SpringMVC/index.html">
<meta property="og:site_name" content="斯人若彩虹 遇上方知有">
<meta property="og:description" content=".back-top{position: fixed;top: 500px;height: 0px;float: right;right: 50px;} .back-top&gt;a{font-weight:bold;width: 50px;height: 50px;text-align: center;text-decoration: none;font-size: 5px;line-height:">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20210317142755778.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20210317142805622.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20210317142829243.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70">
<meta property="og:image" content="https://img-blog.csdnimg.cn/202103171428468.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70">
<meta property="article:published_time" content="2021-03-17T06:19:57.000Z">
<meta property="article:modified_time" content="2021-03-17T07:21:20.000Z">
<meta property="article:author" content="何水浪">
<meta property="article:tag" content="SSM学习笔记">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20210317142755778.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70"><title>SpringMVC学习笔记(所有代码FROM SIKI学院) | 斯人若彩虹 遇上方知有</title><link ref="canonical" href="https://bruce-jj.gitee.io/blog/2021/03/17/SpringMVC/"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.12.1/css/all.min.css" type="text/css"><link rel="stylesheet" href="/blog/css/index.css?v=2.6.2"><script>var Stun = window.Stun || {};
var CONFIG = {
  root: '/blog/',
  algolia: undefined,
  assistSearch: undefined,
  fontIcon: {"prompt":{"success":"fas fa-check-circle","info":"fas fa-arrow-circle-right","warning":"fas fa-exclamation-circle","error":"fas fa-times-circle"},"copyBtn":"fas fa-copy"},
  sidebar: {"offsetTop":"20px","tocMaxDepth":6},
  header: {"enable":true,"showOnPost":true,"scrollDownIcon":false},
  postWidget: {"endText":true},
  nightMode: {"enable":true},
  back2top: {"enable":true},
  codeblock: {"style":"default","highlight":"light","wordWrap":false},
  reward: false,
  fancybox: false,
  zoomImage: {"gapAside":"20px"},
  galleryWaterfall: undefined,
  lazyload: false,
  pjax: undefined,
  externalLink: {"icon":{"enable":true,"name":"fas fa-external-link-alt"}},
  shortcuts: undefined,
  prompt: {"copyButton":"复制","copySuccess":"复制成功","copyError":"复制失败"},
  sourcePath: {"js":"js","css":"css","images":"images"},
};

window.CONFIG = CONFIG;</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/blog/atom.xml" title="斯人若彩虹 遇上方知有" type="application/atom+xml">
</head><body><div class="container" id="container"><header class="header" id="header"><div class="header-inner"><nav class="header-nav header-nav--fixed"><div class="header-nav-inner"><div class="header-nav-menubtn"><i class="fas fa-bars"></i></div><div class="header-nav-menu"><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/blog/"><span class="header-nav-menu-item__icon"><i class="fas fa-home"></i></span><span class="header-nav-menu-item__text">首页</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/blog/archives/"><span class="header-nav-menu-item__icon"><i class="fas fa-folder-open"></i></span><span class="header-nav-menu-item__text">归档</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/blog/categories/"><span class="header-nav-menu-item__icon"><i class="fas fa-layer-group"></i></span><span class="header-nav-menu-item__text">分类</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/blog/tags/"><span class="header-nav-menu-item__icon"><i class="fas fa-tags"></i></span><span class="header-nav-menu-item__text">标签</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/blog/friends/"><span class="header-nav-menu-item__icon"><i class="fas fa-link"></i></span><span class="header-nav-menu-item__text">友链</span></a></div></div><div class="header-nav-search"><span class="header-nav-search__icon"><i class="fas fa-search"></i></span><span class="header-nav-search__text">搜索</span></div><div class="header-nav-mode"><div class="mode"><div class="mode-track"><span class="mode-track-moon"></span><span class="mode-track-sun"></span></div><div class="mode-thumb"></div></div></div></div></nav><div class="header-banner"><div class="header-banner-info"><div class="header-banner-info__title">斯人若彩虹 遇上方知有</div><div class="header-banner-info__subtitle"></div></div></div></div></header><main class="main" id="main"><div class="main-inner"><div class="content-wrap" id="content-wrap"><div class="content" id="content"><!-- Just used to judge whether it is an article page--><div id="is-post"></div><div class="post"><header class="post-header"><h1 class="post-title">SpringMVC学习笔记(所有代码FROM SIKI学院)</h1><div class="post-meta"><span class="post-meta-item post-meta-item--createtime"><span class="post-meta-item__icon"><i class="far fa-calendar-plus"></i></span><span class="post-meta-item__info">发表于</span><span class="post-meta-item__value">2021-03-17</span></span><span class="post-meta-item post-meta-item--updatetime"><span class="post-meta-item__icon"><i class="far fa-calendar-check"></i></span><span class="post-meta-item__info">更新于</span><span class="post-meta-item__value">2021-03-17</span></span><span class="post-meta-item post-meta-item--wordcount"><span class="post-meta-item__icon"><i class="far fa-file-word"></i></span><span class="post-meta-item__info">字数统计</span><span class="post-meta-item__value">6.7k</span></span><span class="post-meta-item post-meta-item--readtime"><span class="post-meta-item__icon"><i class="far fa-clock"></i></span><span class="post-meta-item__info">阅读时长</span><span class="post-meta-item__value">64分</span></span></div></header><div class="post-body"><!-- 页面必备样式 -->
<style>
.back-top{position: fixed;top: 500px;height: 0px;float: right;right: 50px;}
.back-top>a{font-weight:bold;width: 50px;height: 50px;text-align: center;text-decoration: none;font-size: 5px;line-height: 50px;border-radius: 50px;background-color:rgba(255,255,255,0.5);}
</style>
<div class="back-top">
    <a href="#top"> >返回顶部< </a>
</div>
<!-- toc -->
<!-- 必备样式结束 -->


        <h1 id="SpringMVC是什么？"   >
          <a href="#SpringMVC是什么？" class="heading-link"><i class="fas fa-link"></i></a><a href="#SpringMVC是什么？" class="headerlink" title="SpringMVC是什么？"></a>SpringMVC是什么？</h1>
      <pre><code>Spring MVC又叫SpringWebMVC是一个轻量级的基于请求响应的表现层框架。它是Spring框架的一部分。SpringMVC与Struts2都可以替代原始Servlet技术。
</code></pre>

        <h2 id="为什么要使用SpringMVC？"   >
          <a href="#为什么要使用SpringMVC？" class="heading-link"><i class="fas fa-link"></i></a><a href="#为什么要使用SpringMVC？" class="headerlink" title="为什么要使用SpringMVC？"></a>为什么要使用SpringMVC？</h2>
      <p>Spring Web MVC框架提供了MVC(模型 - 视图 - 控制器)架构和用于开发灵活和松散耦合的Web应用程序的组件。 MVC模式导致应用程序的不同方面(输入逻辑，业务逻辑和UI逻辑)分离，同时提供这些元素之间的松散耦合。</p>
<p>1、SpringMVC是极具代表性的MVC框架对初学者学习很有帮助；<br>    a)模型(Model)封装了应用程序数据，通常它们将由Bean对象组成；<br>    b)视图(View)负责渲染模型数据，一般来说它生成客户端浏览器可以解释HTML输出；<br>    c)控制器(Controller)负责处理用户请求并构建适当的模型，并将其传递给视图进行渲染；</p>
<p>2、与Spring框架无缝集成；<br>3、对Servlet轻度封装，框架小巧轻便性能好；<br>4、可使用注解式开发，编码简洁；<br>5、便于测试；<br>6、具有本地化、国际化、类型转换、数据验证等功能；<br>7、使用人群十分广泛，在现在的企业招聘中属于java程序员必备技能之一；</p>

        <h2 id="我能从这门课中学到什么？"   >
          <a href="#我能从这门课中学到什么？" class="heading-link"><i class="fas fa-link"></i></a><a href="#我能从这门课中学到什么？" class="headerlink" title="我能从这门课中学到什么？"></a>我能从这门课中学到什么？</h2>
      <p>1、SpringMVC框架学习：<br>a)了解SpringMVC框架处理流程；<br>b)掌握SpringMVC搭建、配置与使用；<br>c)Spring + SpringMVC + MyBatis 三大框架整合；<br>d)掌握SpringMVC基本参数与复杂参数绑定；<br>e)掌握SpringMVC自定义异常处理类、拦截器、图片上传等操作；<br>f)掌握SpringMVC处理Json格式字符串；</p>
<p>2、SSM框架练习项目：<br>a)使用整合后的SSM框架完成Steam后台游戏管理和前台游戏列表的Demo；</p>
<p>SpringMVC从哪获取？<br>以下网址可以获取Spring框架的所有版本，SpringMVC是Spring框架中的一个子包SpringWebMvc<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://repo.spring.io/release/org/springframework/spring/" >http://repo.spring.io/release/org/springframework/spring/</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span></p>

        <h1 id="Part-1-SpringMVC入门："   >
          <a href="#Part-1-SpringMVC入门：" class="heading-link"><i class="fas fa-link"></i></a><a href="#Part-1-SpringMVC入门：" class="headerlink" title="Part.1 SpringMVC入门："></a>Part.1 SpringMVC入门：</h1>
      
        <h2 id="1、SpringMVC简要处理流程："   >
          <a href="#1、SpringMVC简要处理流程：" class="heading-link"><i class="fas fa-link"></i></a><a href="#1、SpringMVC简要处理流程：" class="headerlink" title="1、SpringMVC简要处理流程："></a>1、SpringMVC简要处理流程：</h2>
      <p><img   src="https://img-blog.csdnimg.cn/20210317142755778.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70" style="width: image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,tepx;height: t_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70px;"  alt="在这里插入图片描述"></p>

        <h2 id="2、HelloSpringMVC：搭建SpringMVC-HelloWorld项目"   >
          <a href="#2、HelloSpringMVC：搭建SpringMVC-HelloWorld项目" class="heading-link"><i class="fas fa-link"></i></a><a href="#2、HelloSpringMVC：搭建SpringMVC-HelloWorld项目" class="headerlink" title="2、HelloSpringMVC：搭建SpringMVC HelloWorld项目"></a>2、HelloSpringMVC：搭建SpringMVC HelloWorld项目</h2>
      <p>a)导包 –&gt; 02_jar -&gt; spring_jar整理 -&gt; spring_mvc；<br>b)DispatcherServlet配置和拦截规则 (前端控制器、任务派发器、前端调度器)；<br>c)使用SpringMVC显示页面；<br>d)使用SpringMVC向前台传递数据；</p>

        <h2 id="3、SpringMVC详细处理流程："   >
          <a href="#3、SpringMVC详细处理流程：" class="heading-link"><i class="fas fa-link"></i></a><a href="#3、SpringMVC详细处理流程：" class="headerlink" title="3、SpringMVC详细处理流程："></a>3、SpringMVC详细处理流程：</h2>
      <p><img   src="https://img-blog.csdnimg.cn/20210317142805622.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70" style="width: image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,tepx;height: t_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70px;"  alt="在这里插入图片描述"></p>

        <h2 id="4、DispatcherServlet-properties内Bean对象："   >
          <a href="#4、DispatcherServlet-properties内Bean对象：" class="heading-link"><i class="fas fa-link"></i></a><a href="#4、DispatcherServlet-properties内Bean对象：" class="headerlink" title="4、DispatcherServlet.properties内Bean对象："></a>4、DispatcherServlet.properties内Bean对象：</h2>
      <p>a)HandlerMapping：处理器映射 ：将请求映射到Handler上并返回处理器执行链<br>i.通过HandlerMapping（处理器映射），可以将Web 请求映射到正确的Handler（处理器）也就是Controller上；<br>ii.DispactherServlet（前端控制器） 将请求交给HandlerMapping，让他检查请求并找到一个合适的HandlerExecutionChain（处理器执行链），这个HandlerExecutionChain 包含一个能处理该请求的Handler；</p>
<p>b)HandlerAdapter：处理器适配器 ：执行具体的逻辑业务<br>i.负责执行DispactherServlet中HandlerExecutionChain的Handler；<br>ii.从Handler中获取ModelAndView（模型与视图）对象，返回给DispactherServlet；</p>
<p>c)ViewResolver：视图解析器 ：解析视图<br>i.通过视图名称解析视图；<br>ii.返回视图对象；</p>
<p>d)HandlerExceptionResolver：处理器异常解析，将异常映射到统一错误页面，常见的404页面，不让用户看到具体的错误，友好提示；<br>e)LocaleResolver：本地化解析，解析客户端信息进行本地化；<br>f)ThemeResolver：主题解析，实现多风格，类似皮肤效果；<br>g)RequestToViewNameTranslator：请求到视图名转换器，当view为空时，从request中获取viewName；FlashMapManager：FlashMap管理器，通常应用在重定向场景；</p>
<p>5、SpringMVC Controller简要说明<br>a)RequestMapping注解使用：<br>i.多请求；<br>ii.限定请求方法；<br>iii.窄化(简化)请求路径;</p>
<p>b)Controller方法返回值：<br>i.ModelAndView：返回模型和视图<br>ii.void：使用原生request，response<br>iii.String：<br>1.返回视图名 viewName；比较推荐使用<br>2.转发 forword；<br>3.重定向 redirect；</p>
<p>iv.自定义类型(JSON) – 需要@ResponseBody注解 - </p>

        <h1 id="Part-2-SpringMVC-amp-Spring-amp-MyBatis整合："   >
          <a href="#Part-2-SpringMVC-amp-Spring-amp-MyBatis整合：" class="heading-link"><i class="fas fa-link"></i></a><a href="#Part-2-SpringMVC-amp-Spring-amp-MyBatis整合：" class="headerlink" title="Part.2 SpringMVC &amp; Spring &amp; MyBatis整合："></a>Part.2 SpringMVC &amp; Spring &amp; MyBatis整合：</h1>
      
        <h2 id="1、整合ssm-3大框架"   >
          <a href="#1、整合ssm-3大框架" class="heading-link"><i class="fas fa-link"></i></a><a href="#1、整合ssm-3大框架" class="headerlink" title="1、整合ssm 3大框架"></a>1、整合ssm 3大框架</h2>
      <p>a)导包 -&gt; spring_Jar整理 -&gt; ssm框架整合包<br>b)配置 -&gt; web.xml<br>i.读取spring配置文件；<br>ii.配置springmvc前端控制器；</p>
<p>c)配置 -&gt; applicationContext.xml<br>i.读取数据库配置文件；<br>ii.配置数据源连接池；<br>iii.开启注解扫描；<br>iv.配置事务核心管理器；<br>v.开启注解事务；<br>vi.配置视图解析器；</p>
<p>vii.配置Mybatis：<br>1.配置sqlSessionFactory；<br>2.配置别名；<br>3.配置mapper工厂；</p>

        <h2 id="2、准备测试用例"   >
          <a href="#2、准备测试用例" class="heading-link"><i class="fas fa-link"></i></a><a href="#2、准备测试用例" class="headerlink" title="2、准备测试用例"></a>2、准备测试用例</h2>
      <p>a)准备 – 测试数据：<br>i.Bean -&gt; 根据个人喜好；<br>ii.数据库表 -&gt; 根据个人喜好；<br>b)导入 – 测试数据 -&gt; 学习项目 -&gt; 后台页面<br>使用整合后的ssm框架，查询数据库测试表，将数据显示到前台</p>

        <h1 id="Part-3-SpringMVC参数绑定与数据交互："   >
          <a href="#Part-3-SpringMVC参数绑定与数据交互：" class="heading-link"><i class="fas fa-link"></i></a><a href="#Part-3-SpringMVC参数绑定与数据交互：" class="headerlink" title="Part.3 SpringMVC参数绑定与数据交互："></a>Part.3 SpringMVC参数绑定与数据交互：</h1>
      
        <h2 id="1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；"   >
          <a href="#1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；" class="heading-link"><i class="fas fa-link"></i></a><a href="#1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；" class="headerlink" title="1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；"></a>1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；</h2>
      <p>a)HttpServletRequest request；<br>b)HttpServletResponse response；<br>c)HttpSession session；<br>d)Model model：将数据存储在request域，前台可以获取；</p>

        <h2 id="2、基本参数绑定：通过id删除游戏信息；"   >
          <a href="#2、基本参数绑定：通过id删除游戏信息；" class="heading-link"><i class="fas fa-link"></i></a><a href="#2、基本参数绑定：通过id删除游戏信息；" class="headerlink" title="2、基本参数绑定：通过id删除游戏信息；"></a>2、基本参数绑定：通过id删除游戏信息；</h2>
      <p>a)Integer、int；<br>b)Float、float；<br>c)Double、double；<br>d)Boolean、boolean；<br>e)String；</p>

        <h2 id="3、Bean对象参数绑定：添加游戏；"   >
          <a href="#3、Bean对象参数绑定：添加游戏；" class="heading-link"><i class="fas fa-link"></i></a><a href="#3、Bean对象参数绑定：添加游戏；" class="headerlink" title="3、Bean对象参数绑定：添加游戏；"></a>3、Bean对象参数绑定：添加游戏；</h2>
      <p>4、包装类参数绑定：多条件查询，并将结果显示在页面上；<br>5、解决表单post提交乱码：在web.xml中配置过滤器；</p>

        <h2 id="复杂类型参数绑定："   >
          <a href="#复杂类型参数绑定：" class="heading-link"><i class="fas fa-link"></i></a><a href="#复杂类型参数绑定：" class="headerlink" title="复杂类型参数绑定："></a>复杂类型参数绑定：</h2>
      <p>1、Array数组类型的参数绑定：为页面增加多选框，获取选定游戏信息的id，后续逻辑自行选择；<br>2、List类型的参数绑定：获取所有游戏价格，并且计算总价；</p>

        <h2 id="Json数据交互："   >
          <a href="#Json数据交互：" class="heading-link"><i class="fas fa-link"></i></a><a href="#Json数据交互：" class="headerlink" title="Json数据交互："></a>Json数据交互：</h2>
      <p> Json介绍：<span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://www.bejson.com/knownjson/aboutjson/" >http://www.bejson.com/knownjson/aboutjson/</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span><br>a)导包，配置注解驱动；<br>b)创建自己的Json对象；<br>c)发送和接收Json字符串；<br>d)修改游戏信息，在弹出层内回显数据；<br>e)使用@RequestBody完成List和数组参数绑定，获取所有游戏的名称，在后台打印；</p>

        <h1 id="Part-4-异常处理器与拦截器"   >
          <a href="#Part-4-异常处理器与拦截器" class="heading-link"><i class="fas fa-link"></i></a><a href="#Part-4-异常处理器与拦截器" class="headerlink" title="Part.4 异常处理器与拦截器"></a>Part.4 异常处理器与拦截器</h1>
      
        <h2 id="1、通过实现HandlerExceptionResolver接口完成异常处理；"   >
          <a href="#1、通过实现HandlerExceptionResolver接口完成异常处理；" class="heading-link"><i class="fas fa-link"></i></a><a href="#1、通过实现HandlerExceptionResolver接口完成异常处理；" class="headerlink" title="1、通过实现HandlerExceptionResolver接口完成异常处理；"></a>1、通过实现HandlerExceptionResolver接口完成异常处理；</h2>
      <p>a)异常处理器原理；<br><img   src="https://img-blog.csdnimg.cn/20210317142829243.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70" style="width: image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,tepx;height: t_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70px;"  alt="在这里插入图片描述"></p>
<p>b)使用异常处理器捕获运行时异常；<br>c)使用异常处理器捕获自定义异常；</p>

        <h2 id="2、通过注解完成全局异常处理；"   >
          <a href="#2、通过注解完成全局异常处理；" class="heading-link"><i class="fas fa-link"></i></a><a href="#2、通过注解完成全局异常处理；" class="headerlink" title="2、通过注解完成全局异常处理；"></a>2、通过注解完成全局异常处理；</h2>
      <p>a)通过@ControllerAdvice注解使@ExceptionHandler异常处理注解应用到所有使用@RequestMapping的方法上；<br>b)处理运行时异常：直接打印错误信息；<br>c)处理自定义异常：将错误信息输出到error页面上； </p>

        <h2 id="拦截器Interceptor"   >
          <a href="#拦截器Interceptor" class="heading-link"><i class="fas fa-link"></i></a><a href="#拦截器Interceptor" class="headerlink" title="拦截器Interceptor"></a>拦截器Interceptor</h2>
      
        <h3 id="1、SpringMvc中的拦截器："   >
          <a href="#1、SpringMvc中的拦截器：" class="heading-link"><i class="fas fa-link"></i></a><a href="#1、SpringMvc中的拦截器：" class="headerlink" title="1、SpringMvc中的拦截器："></a>1、SpringMvc中的拦截器：</h3>
      <p>a)SpringMvc拦截器帮我们按照一定规则拦截请求，后根据开发人员自定义的拦截逻辑进行处理；<br>b)自定义拦截器需要实现HandlerInterceptor接口；<br>c)自定义的拦截器实现类需要在SpringMvc配置文件中配置；<br>d)可以配置多个拦截器，配置的顺序会影响到拦截器的执行顺序，配置在前的先执行；<br>e)HandlerInterceptor有3个接口：<br>i.preHandle 预处理：在拦截方法前执行；<br>ii.postHandle 后处理：在拦截方法后执行；<br>iii.afterCompletion 渲染后处理：在页面渲染后执行；<br>f)拦截器也体现了AOP思想；<br>g)拦截器的应用：权限检查，日志记录，性能检测等；</p>

        <h3 id="2、拦截器的执行流程图："   >
          <a href="#2、拦截器的执行流程图：" class="heading-link"><i class="fas fa-link"></i></a><a href="#2、拦截器的执行流程图：" class="headerlink" title="2、拦截器的执行流程图："></a>2、拦截器的执行流程图：</h3>
      <p><img   src="https://img-blog.csdnimg.cn/202103171428468.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70" style="width: image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,tepx;height: t_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQzNDQ1MDY3,size_16,color_FFFFFF,t_70px;"  alt="在这里插入图片描述"></p>

        <h3 id="3、拦截器的执行规则；"   >
          <a href="#3、拦截器的执行规则；" class="heading-link"><i class="fas fa-link"></i></a><a href="#3、拦截器的执行规则；" class="headerlink" title="3、拦截器的执行规则；"></a>3、拦截器的执行规则；</h3>
      <p>a)自定义2个拦截器，并在主配置文件中配置好；<br>b)运行服务进入拦截器，观察执行流程；</p>

        <h3 id="4、总结的五条拦截器规则；"   >
          <a href="#4、总结的五条拦截器规则；" class="heading-link"><i class="fas fa-link"></i></a><a href="#4、总结的五条拦截器规则；" class="headerlink" title="4、总结的五条拦截器规则；"></a>4、总结的五条拦截器规则；</h3>
      <p>a)preHandle预处理：————–根据拦截器定义的顺序，正向执行；<br>b)postHandle后处理：————-根据拦截器定义的顺序，逆向执行；<br>c)afterCompletion渲染后处理：—根据拦截器定义的顺序，逆向执行；<br>d)postHandle预处理：————-所有拦截器都返回成功调用；<br>e)atterCompletion渲染后处理：—preHandle返回true调用；</p>

        <h3 id="5、使用拦截器开发用户登录校验；"   >
          <a href="#5、使用拦截器开发用户登录校验；" class="heading-link"><i class="fas fa-link"></i></a><a href="#5、使用拦截器开发用户登录校验；" class="headerlink" title="5、使用拦截器开发用户登录校验；"></a>5、使用拦截器开发用户登录校验；</h3>
      <p>a)需要登录才可以访问列表页；<br>b)如果未登录重定向到登录页面；</p>

        <h3 id="6、使用拦截器搭配异常处理器完成用户登录时的异常处理；"   >
          <a href="#6、使用拦截器搭配异常处理器完成用户登录时的异常处理；" class="heading-link"><i class="fas fa-link"></i></a><a href="#6、使用拦截器搭配异常处理器完成用户登录时的异常处理；" class="headerlink" title="6、使用拦截器搭配异常处理器完成用户登录时的异常处理；"></a>6、使用拦截器搭配异常处理器完成用户登录时的异常处理；</h3>
      <p>a)使用自定义异常处理器捕获登录时异常；<br>b)如果出现异常，将异常信息发送到登录页面提示；</p>

        <h3 id="7、静态资源放行；"   >
          <a href="#7、静态资源放行；" class="heading-link"><i class="fas fa-link"></i></a><a href="#7、静态资源放行；" class="headerlink" title="7、静态资源放行；"></a>7、静态资源放行；</h3>
      <p>a)在web.xml配置DispatcherServlet的url-pattern以扩展名结尾，例如*.do，*.html 等；<br>b)在web.xml配置default servlet-mapping的url-pattern，以目录形式和扩展名形式；<br>c)在springmvc.xml中配置<span class="exturl"><a class="exturl__link"   href="mvc:resources/" >mvc:resources/</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>，该方法需要注意以下几点：<br>i.需要开启mvc:annotation-driven注解驱动；<br>ii.如果配置了拦截器，需要在拦截器中进行过滤，否则会被拦截；<br>iii.路径名不要打错 ;</p>

        <h3 id="8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；"   >
          <a href="#8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；" class="heading-link"><i class="fas fa-link"></i></a><a href="#8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；" class="headerlink" title="8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；"></a>8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；</h3>
      <p>更多关于RESTful风格的介绍网上查查；</p>
<p>使用RESTful前：<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/save" >http://127.0.0.1/item/save</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>            POST     新增物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/delete" >http://127.0.0.1/item/delete</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>             GET/POST     删除物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/update" >http://127.0.0.1/item/update</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>         POST     修改物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/query.do?id=1" >http://127.0.0.1/item/query.do?id=1</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>    GET          根据id查询物品</p>
<p>使用RESTful后：<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item" >http://127.0.0.1/item</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>                POST     新增物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/1" >http://127.0.0.1/item/1</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>             DELETE     根据id删除物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item" >http://127.0.0.1/item</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>                 PUT         修改物品<br><span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://127.0.0.1/item/1" >http://127.0.0.1/item/1</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span>             GET          根据id查询物品</p>
<p>RESTful风格开发对Http协议中的基本方法的使用<br>POST    INSERT    增    邮寄一个新的<br>DELETE    DELETE    删    仍了，不要了<br>GET     SELECT    查    获取一个<br>PUT        UPDATE    改    往这个里边放点东西</p>
<p>使用Springmvc实现RESTful风格开发；<br>a)使用物品id当作请求路径，点击按钮，跳转到具体的页面；<br>b)当使用ajax时，页面不会跳转，需要到ajax回调中处理；</p>

        <h1 id="SPRINGMVC-PROJECT-1"   >
          <a href="#SPRINGMVC-PROJECT-1" class="heading-link"><i class="fas fa-link"></i></a><a href="#SPRINGMVC-PROJECT-1" class="headerlink" title="SPRINGMVC-PROJECT-1"></a>SPRINGMVC-PROJECT-1</h1>
      
        <h2 id="前端请求页面form-jsp"   >
          <a href="#前端请求页面form-jsp" class="heading-link"><i class="fas fa-link"></i></a><a href="#前端请求页面form-jsp" class="headerlink" title="前端请求页面form.jsp"></a>前端请求页面form.jsp</h2>
      <figure class="highlight jsp"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&lt;%@ page language=<span class="string">&quot;java&quot;</span> contentType=<span class="string">&quot;text/html; charset=UTF-8&quot;</span></span><br><span class="line">    pageEncoding=<span class="string">&quot;UTF-8&quot;</span>%&gt;</span><br><span class="line">&lt;!DOCTYPE html PUBLIC <span class="string">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span class="string">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span>&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">&lt;meta http-equiv=<span class="string">&quot;Content-Type&quot;</span> content=<span class="string">&quot;text/html; charset=UTF-8&quot;</span>&gt;</span><br><span class="line">&lt;title&gt;Insert title here&lt;/title&gt;</span><br><span class="line">&lt;/head&gt;</span><br><span class="line">&lt;body&gt;</span><br><span class="line">	&lt;form action=<span class="string">&quot;$&#123;pageContext.request.contextPath&#125;/mylist.do&quot;</span> method=<span class="string">&quot;get&quot;</span>&gt;</span><br><span class="line">		&lt;input type=<span class="string">&quot;submit&quot;</span> value=<span class="string">&quot;提交&quot;</span>&gt;</span><br><span class="line">	&lt;/form&gt;</span><br><span class="line">&lt;/body&gt;</span><br><span class="line">&lt;/html&gt;</span><br></pre></td></tr></table></div></figure>


        <h2 id="WEB配置文件-web-xml"   >
          <a href="#WEB配置文件-web-xml" class="heading-link"><i class="fas fa-link"></i></a><a href="#WEB配置文件-web-xml" class="headerlink" title="WEB配置文件 web.xml"></a>WEB配置文件 web.xml</h2>
      <figure class="highlight xml"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">web-app</span> <span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;</span> <span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd&quot;</span> <span class="attr">id</span>=<span class="string">&quot;WebApp_ID&quot;</span> <span class="attr">version</span>=<span class="string">&quot;3.1&quot;</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">display-name</span>&gt;</span>ssm_spring_mvc<span class="tag">&lt;/<span class="name">display-name</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="tag">&lt;<span class="name">servlet</span>&gt;</span></span><br><span class="line">  	<span class="tag">&lt;<span class="name">servlet-name</span>&gt;</span>springmvc<span class="tag">&lt;/<span class="name">servlet-name</span>&gt;</span></span><br><span class="line">  	<span class="tag">&lt;<span class="name">servlet-class</span>&gt;</span>org.springframework.web.servlet.DispatcherServlet<span class="tag">&lt;/<span class="name">servlet-class</span>&gt;</span></span><br><span class="line">  	<span class="tag">&lt;<span class="name">init-param</span>&gt;</span></span><br><span class="line">  		<span class="comment">&lt;!-- 读取springmvc配置文件 --&gt;</span></span><br><span class="line">  		<span class="tag">&lt;<span class="name">param-name</span>&gt;</span>contextConfigLocation<span class="tag">&lt;/<span class="name">param-name</span>&gt;</span></span><br><span class="line">  		<span class="tag">&lt;<span class="name">param-value</span>&gt;</span>classpath:springmvc.xml<span class="tag">&lt;/<span class="name">param-value</span>&gt;</span></span><br><span class="line">  	<span class="tag">&lt;/<span class="name">init-param</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">servlet</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="tag">&lt;<span class="name">servlet-mapping</span>&gt;</span></span><br><span class="line">  	<span class="tag">&lt;<span class="name">servlet-name</span>&gt;</span>springmvc<span class="tag">&lt;/<span class="name">servlet-name</span>&gt;</span></span><br><span class="line">  	<span class="comment">&lt;!-- 拦截规则 --&gt;</span></span><br><span class="line">  	<span class="comment">&lt;!--1 *.htm *.do *.action   以扩展名方式进行拦截，不拦截静态资源  .jpg .css .js .png   什么情况下都可以使用</span></span><br><span class="line"><span class="comment">  		2 / 不拦截 jsp 拦截静态资源 .jpg .css .js .png  </span></span><br><span class="line"><span class="comment">  		/* 全都拦截 包括jsp 以及所有静态资源 不推荐使用的--&gt;</span></span><br><span class="line">  	<span class="tag">&lt;<span class="name">url-pattern</span>&gt;</span>*.do<span class="tag">&lt;/<span class="name">url-pattern</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">servlet-mapping</span>&gt;</span></span><br><span class="line">  </span><br><span class="line">  <span class="tag">&lt;<span class="name">welcome-file-list</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>index.html<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>index.htm<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>index.jsp<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>default.html<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>default.htm<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">welcome-file</span>&gt;</span>default.jsp<span class="tag">&lt;/<span class="name">welcome-file</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">welcome-file-list</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">web-app</span>&gt;</span></span><br></pre></td></tr></table></div></figure>


        <h2 id="SPRINGMVC配置文件-springmvc-xml"   >
          <a href="#SPRINGMVC配置文件-springmvc-xml" class="heading-link"><i class="fas fa-link"></i></a><a href="#SPRINGMVC配置文件-springmvc-xml" class="headerlink" title="SPRINGMVC配置文件 springmvc.xml"></a>SPRINGMVC配置文件 springmvc.xml</h2>
      <figure class="highlight xml"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">beans</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://www.springframework.org/schema/beans&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:context</span>=<span class="string">&quot;http://www.springframework.org/schema/context&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:mvc</span>=<span class="string">&quot;http://www.springframework.org/schema/mvc&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:aop</span>=<span class="string">&quot;http://www.springframework.org/schema/aop&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd&quot;</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 开启注解扫描 基本包下有 bean,controller层.. --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">context:component-scan</span> <span class="attr">base-package</span>=<span class="string">&quot;com.sikiedu&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">context:component-scan</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 配置视图解析器  配置viewName 前缀与后缀 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">class</span>=<span class="string">&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;prefix&quot;</span> <span class="attr">value</span>=<span class="string">&quot;/WEB-INF/jsp/&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;suffix&quot;</span> <span class="attr">value</span>=<span class="string">&quot;.jsp&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">		</span><br><span class="line"><span class="tag">&lt;/<span class="name">beans</span>&gt;</span></span><br><span class="line"></span><br></pre></td></tr></table></div></figure>

        <h2 id="BEAN对象-ItemInfo-java"   >
          <a href="#BEAN对象-ItemInfo-java" class="heading-link"><i class="fas fa-link"></i></a><a href="#BEAN对象-ItemInfo-java" class="headerlink" title="BEAN对象 ItemInfo.java"></a>BEAN对象 ItemInfo.java</h2>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ItemInfo</span> </span>&#123;</span><br><span class="line">	<span class="comment">//id</span></span><br><span class="line">	<span class="keyword">private</span> String item_id;</span><br><span class="line">	<span class="comment">//name</span></span><br><span class="line">	<span class="keyword">private</span> String item_name;</span><br><span class="line">	<span class="comment">//type</span></span><br><span class="line">	<span class="keyword">private</span> String item_type;</span><br><span class="line">	<span class="comment">//price</span></span><br><span class="line">	<span class="keyword">private</span> String item_price;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>


        <h2 id="Controller层-ItemController-java"   >
          <a href="#Controller层-ItemController-java" class="heading-link"><i class="fas fa-link"></i></a><a href="#Controller层-ItemController-java" class="headerlink" title="Controller层 ItemController.java"></a>Controller层 ItemController.java</h2>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&lt;!-- 注解表示是控制层 通过springmvc注解扫描 --&gt;</span><br><span class="line">&lt;!-- RequestMapping对应前端页面的请求路径 --&gt;</span><br><span class="line"><span class="meta">@Controller</span> </span><br><span class="line"><span class="meta">@RequestMapping(value=&quot;/item/&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ItemController</span>  </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="comment">//显示页面	</span></span><br><span class="line">	<span class="meta">@RequestMapping(value= &#123;&quot;list.do&quot;, &quot;mylist.do&quot;&#125;, method= &#123;RequestMethod.GET, RequestMethod.POST&#125;)</span></span><br><span class="line">	&lt;!-- 指定返回类型是ModelAndView 表示最后会跳转页面 --&gt;</span><br><span class="line">	<span class="function"><span class="keyword">public</span> ModelAndView <span class="title">list</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		ModelAndView mav = <span class="keyword">new</span> ModelAndView();</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//传递数据</span></span><br><span class="line">		<span class="comment">//准备一些测试数据</span></span><br><span class="line">		ItemInfo info1 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;1&quot;</span>, <span class="string">&quot;王者荣耀&quot;</span>, <span class="string">&quot;MOBA&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info2 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;2&quot;</span>, <span class="string">&quot;守望先锋&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;198&quot;</span>) ;</span><br><span class="line">		ItemInfo info3 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;3&quot;</span>, <span class="string">&quot;吃鸡&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;98&quot;</span>) ;</span><br><span class="line">		ItemInfo info4 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;4&quot;</span>, <span class="string">&quot;魔兽世界&quot;</span>, <span class="string">&quot;MMORPG&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info5 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;5&quot;</span>, <span class="string">&quot;保卫萝卜&quot;</span>, <span class="string">&quot;休闲&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		</span><br><span class="line">		List&lt;ItemInfo&gt; itemList = <span class="keyword">new</span> ArrayList&lt;ItemInfo&gt;();</span><br><span class="line">		itemList.add(info1);</span><br><span class="line">		itemList.add(info2);</span><br><span class="line">		itemList.add(info3);</span><br><span class="line">		itemList.add(info4);</span><br><span class="line">		itemList.add(info5);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//将游戏列表返回给前台</span></span><br><span class="line">		mav.addObject(<span class="string">&quot;itemList&quot;</span>, itemList);</span><br><span class="line">		</span><br><span class="line">		mav.setViewName(<span class="string">&quot;item_list&quot;</span>);</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">return</span> mav;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="meta">@RequestMapping(value= &#123;&quot;mylist1.do&quot;&#125;, method= &#123;RequestMethod.GET, RequestMethod.POST&#125;)</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> ModelAndView <span class="title">list1</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		ModelAndView mav = <span class="keyword">new</span> ModelAndView();</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//传递数据</span></span><br><span class="line">		<span class="comment">//准备一些测试数据</span></span><br><span class="line">		ItemInfo info1 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;1&quot;</span>, <span class="string">&quot;王者荣耀&quot;</span>, <span class="string">&quot;MOBA&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info2 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;2&quot;</span>, <span class="string">&quot;守望先锋&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;198&quot;</span>) ;</span><br><span class="line">		ItemInfo info3 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;3&quot;</span>, <span class="string">&quot;吃鸡&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;98&quot;</span>) ;</span><br><span class="line">		ItemInfo info4 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;4&quot;</span>, <span class="string">&quot;魔兽世界&quot;</span>, <span class="string">&quot;MMORPG&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info5 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;5&quot;</span>, <span class="string">&quot;保卫萝卜&quot;</span>, <span class="string">&quot;休闲&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		</span><br><span class="line">		List&lt;ItemInfo&gt; itemList = <span class="keyword">new</span> ArrayList&lt;ItemInfo&gt;();</span><br><span class="line">		itemList.add(info1);</span><br><span class="line">		itemList.add(info2);</span><br><span class="line">		itemList.add(info3);</span><br><span class="line">		itemList.add(info4);</span><br><span class="line">		itemList.add(info5);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//将游戏列表返回给前台 指定Viewname即显示的页面是哪一个？</span></span><br><span class="line">		</span><br><span class="line">		mav.addObject(<span class="string">&quot;itemList&quot;</span>, itemList);		</span><br><span class="line">		mav.setViewName(<span class="string">&quot;item_list&quot;</span>);</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">return</span> mav;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//void</span></span><br><span class="line">	<span class="meta">@RequestMapping(value=&quot;&quot;)</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">voidTest</span><span class="params">(HttpServletRequest request, HttpServletResponse response)</span> <span class="keyword">throws</span> ServletException, IOException </span>&#123;</span><br><span class="line">		<span class="comment">//获取参数</span></span><br><span class="line">		request.getParameter(<span class="string">&quot;&quot;</span>);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//转发</span></span><br><span class="line">		request.getRequestDispatcher(<span class="string">&quot;&quot;</span>).forward(request, response);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//重定向</span></span><br><span class="line">		response.sendRedirect(request.getContextPath() + <span class="string">&quot;/xx.jsp&quot;</span>);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//String 转发</span></span><br><span class="line">	<span class="meta">@RequestMapping(&quot;forwardString.do&quot;)</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> String <span class="title">forwardString</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;forward:mylist1.do&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//String 重定向</span></span><br><span class="line">	<span class="meta">@RequestMapping(&quot;redirectString.do&quot;)</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> String <span class="title">redirectString</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;redirect:/form.jsp&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	</span><br><span class="line">	<span class="comment">//String </span></span><br><span class="line">	<span class="meta">@RequestMapping(&quot;testList.do&quot;)</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> String <span class="title">testList</span><span class="params">(Model model)</span> </span>&#123;</span><br><span class="line">		<span class="comment">//传递数据</span></span><br><span class="line">		<span class="comment">//准备一些测试数据</span></span><br><span class="line">		ItemInfo info1 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;1&quot;</span>, <span class="string">&quot;王者荣耀&quot;</span>, <span class="string">&quot;MOBA&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info2 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;2&quot;</span>, <span class="string">&quot;守望先锋&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;198&quot;</span>) ;</span><br><span class="line">		ItemInfo info3 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;3&quot;</span>, <span class="string">&quot;吃鸡&quot;</span>, <span class="string">&quot;射击&quot;</span>, <span class="string">&quot;98&quot;</span>) ;</span><br><span class="line">		ItemInfo info4 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;4&quot;</span>, <span class="string">&quot;魔兽世界&quot;</span>, <span class="string">&quot;MMORPG&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		ItemInfo info5 = <span class="keyword">new</span> ItemInfo(<span class="string">&quot;5&quot;</span>, <span class="string">&quot;保卫萝卜&quot;</span>, <span class="string">&quot;休闲&quot;</span>, <span class="string">&quot;0&quot;</span>) ;</span><br><span class="line">		</span><br><span class="line">		List&lt;ItemInfo&gt; itemList = <span class="keyword">new</span> ArrayList&lt;ItemInfo&gt;();</span><br><span class="line">		itemList.add(info1);</span><br><span class="line">		itemList.add(info2);</span><br><span class="line">		itemList.add(info3);</span><br><span class="line">		itemList.add(info4);</span><br><span class="line">		itemList.add(info5);</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//将游戏列表返回给前台</span></span><br><span class="line">		model.addAttribute(<span class="string">&quot;itemList&quot;</span>, itemList);</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;item_list&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>

        <h2 id="数据显示页面-item-list-jsp"   >
          <a href="#数据显示页面-item-list-jsp" class="heading-link"><i class="fas fa-link"></i></a><a href="#数据显示页面-item-list-jsp" class="headerlink" title="数据显示页面 item_list.jsp"></a>数据显示页面 item_list.jsp</h2>
      <figure class="highlight jsp"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br></pre></td><td class="code"><pre><span class="line">&lt;%@ page language=<span class="string">&quot;java&quot;</span> contentType=<span class="string">&quot;text/html; charset=UTF-8&quot;</span> pageEncoding=<span class="string">&quot;UTF-8&quot;</span>%&gt;</span><br><span class="line">&lt;%@ taglib uri=<span class="string">&quot;http://java.sun.com/jsp/jstl/core&quot;</span> prefix=<span class="string">&quot;c&quot;</span>%&gt;</span><br><span class="line">&lt;!DOCTYPE html PUBLIC <span class="string">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span class="string">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span>&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">    &lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">&quot;UTF-8&quot;</span>&gt;</span><br><span class="line">		&lt;title&gt;游戏管理后台&lt;/title&gt;</span><br><span class="line">        &lt;meta name=<span class="string">&quot;viewport&quot;</span> content=<span class="string">&quot;initial-scale=1.0,maximum-scale=1.0,user-scalable=no&quot;</span>&gt;</span><br><span class="line">        &lt;meta http-equiv=<span class="string">&quot;X-UA-Compatible&quot;</span> content=<span class="string">&quot;IE=edge&quot;</span>&gt;</span><br><span class="line">    &lt;/head&gt;</span><br><span class="line">    &lt;body <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;side_menu_active side_menu_expanded&quot;</span>&gt;</span><br><span class="line">        &lt;div id=<span class="string">&quot;page_wrapper&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">            &lt;!-- header --&gt;</span><br><span class="line">            &lt;header id=<span class="string">&quot;main_header&quot;</span>&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;container-fluid&quot;</span>&gt;</span><br><span class="line">                	&lt;!--logo--&gt;</span><br><span class="line">                    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;brand_section&quot;</span>&gt;</span><br><span class="line">                        &lt;a href=<span class="string">&quot;#&quot;</span>&gt;&lt;img src=<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/picture/logo01.png&quot;</span> alt=<span class="string">&quot;site_logo&quot;</span> width=<span class="string">&quot;108&quot;</span> height=<span class="string">&quot;40&quot;</span> style=<span class="string">&quot;margin-top: 5px&quot;</span>&gt;&lt;/a&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;header_user_actions dropdown&quot;</span>&gt;</span><br><span class="line">                        &lt;div data-toggle=<span class="string">&quot;dropdown&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;dropdown-toggle user_dropdown&quot;</span>&gt;</span><br><span class="line">                            &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;user_avatar&quot;</span>&gt;</span><br><span class="line">                                &lt;img src=<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/picture/head01.png&quot;</span> width=<span class="string">&quot;38&quot;</span> height=<span class="string">&quot;38&quot;</span>&gt;</span><br><span class="line">                            &lt;/div&gt;</span><br><span class="line">                            &lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;caret&quot;</span>&gt;&lt;/span&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                        &lt;ul <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;dropdown-menu dropdown-menu-right&quot;</span>&gt;</span><br><span class="line">                            &lt;li&gt;&lt;a href=<span class="string">&quot;#&quot;</span>&gt;个人中心&lt;/a&gt;&lt;/li&gt;</span><br><span class="line">                            &lt;li&gt;&lt;a href=<span class="string">&quot;#&quot;</span>&gt;注销&lt;/a&gt;&lt;/li&gt;</span><br><span class="line">                        &lt;/ul&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">            &lt;/header&gt;</span><br><span class="line"></span><br><span class="line">            &lt;!-- main content --&gt;</span><br><span class="line">            &lt;div id=<span class="string">&quot;main_wrapper&quot;</span>&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;container-fluid&quot;</span>&gt;</span><br><span class="line">                    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;row&quot;</span>&gt;</span><br><span class="line">                        &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-md-12&quot;</span>&gt;</span><br><span class="line">                            &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;row&quot;</span>&gt;</span><br><span class="line">                                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-md-10&quot;</span>&gt;</span><br><span class="line">                                    &lt;table <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;table table-yuk2 toggle-arrow-tiny&quot;</span> id=<span class="string">&quot;footable_demo&quot;</span> data-filter=<span class="string">&quot;#textFilter&quot;</span> data-page-size=<span class="string">&quot;5&quot;</span>&gt;</span><br><span class="line">                                        &lt;thead&gt;</span><br><span class="line">                                            &lt;tr&gt;</span><br><span class="line">                                            	&lt;!--描述：商品数据标签--&gt;</span><br><span class="line">                                                &lt;th&gt;ID&lt;/th&gt;</span><br><span class="line">                                                &lt;th&gt;游戏名称&lt;/th&gt;</span><br><span class="line">                                                &lt;th&gt;类型&lt;/th&gt;</span><br><span class="line">                                                &lt;th&gt;原价&lt;/th&gt;</span><br><span class="line">                                            &lt;/tr&gt;</span><br><span class="line">                                        &lt;/thead&gt;</span><br><span class="line">                                        &lt;tbody&gt;</span><br><span class="line">                                       		&lt;c:forEach items=<span class="string">&quot;$&#123;itemList &#125;&quot;</span> <span class="keyword">var</span>=<span class="string">&quot;item&quot;</span>&gt;</span><br><span class="line">	                                        	&lt;tr&gt;</span><br><span class="line">	                                                &lt;td&gt;$&#123;item.item_id &#125;&lt;/td&gt;</span><br><span class="line">	                                                &lt;td&gt;$&#123;item.item_name &#125;&lt;/td&gt;</span><br><span class="line">	                                                &lt;td&gt;$&#123;item.item_type &#125;&lt;/td&gt;</span><br><span class="line">	                                                &lt;td&gt;$&#123;item.item_price &#125;&lt;/td&gt;</span><br><span class="line">	                                                </span><br><span class="line">	                                                &lt;td data-value=<span class="string">&quot;1&quot;</span>&gt;</span><br><span class="line">	                                                	&lt;a herf=<span class="string">&quot;#&quot;</span> id=<span class="string">&quot;edit_btn&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-xs btn-info&quot;</span> data-toggle=<span class="string">&quot;modal&quot;</span> data-target=<span class="string">&quot;#editLayer&quot;</span> onclick=<span class="string">&quot;editGoods(&#x27;$&#123;item.item_id&#125;&#x27;)&quot;</span>&gt;修改&lt;/a&gt;</span><br><span class="line">	                                                	&lt;a herf=<span class="string">&quot;#&quot;</span>  id=<span class="string">&quot;del_btn&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-xs btn-danger&quot;</span> onclick=<span class="string">&quot;deleteGoods(&#x27;$&#123;item.item_id&#125;&#x27;)&quot;</span>&gt;删除&lt;/a&gt;</span><br><span class="line">	                                                &lt;/td&gt;</span><br><span class="line">	                                           	&lt;/tr&gt;</span><br><span class="line">                                        	&lt;/c:forEach&gt;</span><br><span class="line">                                        &lt;/tbody&gt;</span><br><span class="line">                                        &lt;tfoot <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;hide-if-no-paging&quot;</span>&gt;</span><br><span class="line">                                            &lt;tr&gt;</span><br><span class="line">                                                &lt;td colspan=<span class="string">&quot;5&quot;</span>&gt;</span><br><span class="line">                                                    &lt;ul <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;pagination pagination-sm&quot;</span>&gt;&lt;/ul&gt;</span><br><span class="line">                                                &lt;/td&gt;</span><br><span class="line">                                            &lt;/tr&gt;</span><br><span class="line">                                        &lt;/tfoot&gt;</span><br><span class="line">                                    &lt;/table&gt;</span><br><span class="line">                                &lt;/div&gt;</span><br><span class="line">                            &lt;/div&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">            </span><br><span class="line">            &lt;!-- edit layer --&gt;</span><br><span class="line">            &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal fade&quot;</span> id=<span class="string">&quot;editLayer&quot;</span>&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-dialog modal-content&quot;</span>&gt;</span><br><span class="line">                    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-content&quot;</span>&gt;</span><br><span class="line">                        &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-header&quot;</span>&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;close&quot;</span> data-dismiss=<span class="string">&quot;modal&quot;</span>&gt;&lt;span aria-hidden=<span class="string">&quot;true&quot;</span>&gt;&amp;times;&lt;/span&gt;&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;sr-only&quot;</span>&gt;Close&lt;/span&gt;&lt;/button&gt;</span><br><span class="line">                            &lt;h4 <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-title&quot;</span>&gt;修改游戏信息&lt;/h4&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                   	&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-body&quot;</span>&gt;</span><br><span class="line">                        &lt;!--游戏修改详情弹出层表单--&gt;</span><br><span class="line">	                    &lt;form <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-horizontal&quot;</span> id=<span class="string">&quot;edit_item_form&quot;</span>&gt;</span><br><span class="line">	                    	&lt;!-- 游戏id隐藏域 --&gt;</span><br><span class="line">							&lt;input type=<span class="string">&quot;hidden&quot;</span> id=<span class="string">&quot;edit_item_id&quot;</span> name=<span class="string">&quot;item_id&quot;</span>/&gt;</span><br><span class="line">							&lt;!-- 游戏名称 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;edit_item_name&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;游戏名称&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;edit_item_name&quot;</span> placeholder=<span class="string">&quot;游戏名称&quot;</span> name=<span class="string">&quot;item_name&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">							&lt;!-- 游戏类型 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;edit_item_price&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;类型&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;edit_item_price&quot;</span> placeholder=<span class="string">&quot;类型&quot;</span> name=<span class="string">&quot;item_price&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">							&lt;!-- 游戏原价 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;edit_item_price&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;原价&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;edit_item_price&quot;</span> placeholder=<span class="string">&quot;原价&quot;</span> name=<span class="string">&quot;item_price&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">						&lt;/form&gt;  </span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                        &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-footer&quot;</span>&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-default btn-sm&quot;</span> data-dismiss=<span class="string">&quot;modal&quot;</span>&gt;取消&lt;/button&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-primary btn-sm&quot;</span> onclick=<span class="string">&quot;updateItem()&quot;</span>&gt;确认修改&lt;/button&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">            </span><br><span class="line">             &lt;!-- add layer --&gt;</span><br><span class="line">            &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal fade&quot;</span> id=<span class="string">&quot;addLayer&quot;</span>&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-dialog modal-content&quot;</span>&gt;</span><br><span class="line">                    &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-content&quot;</span>&gt;</span><br><span class="line">                        &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-header&quot;</span>&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;close&quot;</span> data-dismiss=<span class="string">&quot;modal&quot;</span>&gt;&lt;span aria-hidden=<span class="string">&quot;true&quot;</span>&gt;&amp;times;&lt;/span&gt;&lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;sr-only&quot;</span>&gt;Close&lt;/span&gt;&lt;/button&gt;</span><br><span class="line">                            &lt;h4 <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-title&quot;</span>&gt;新增游戏&lt;/h4&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                   	&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-body&quot;</span>&gt;</span><br><span class="line">                        &lt;!--添加游戏弹出层表单--&gt;</span><br><span class="line">	                    &lt;form <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-horizontal&quot;</span> id=<span class="string">&quot;add_item_form&quot;</span>&gt;</span><br><span class="line">	                    	&lt;!-- 游戏id隐藏域 --&gt;</span><br><span class="line">							&lt;input type=<span class="string">&quot;hidden&quot;</span> id=<span class="string">&quot;add_item_id&quot;</span> name=<span class="string">&quot;item_id&quot;</span>/&gt;</span><br><span class="line">							&lt;!-- 游戏名称 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;add_item_name&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;游戏名称&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;add_item_name&quot;</span> placeholder=<span class="string">&quot;游戏名称&quot;</span> name=<span class="string">&quot;item_name&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">							&lt;!-- 游戏类型 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;add_item_price&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;类型&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;add_item_price&quot;</span> placeholder=<span class="string">&quot;类型&quot;</span> name=<span class="string">&quot;item_price&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">							&lt;!-- 游戏原价 --&gt;</span><br><span class="line">							&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-group&quot;</span>&gt;</span><br><span class="line">								&lt;label <span class="keyword">for</span>=<span class="string">&quot;add_item_price&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-2 control-label&quot;</span>&gt;原价&lt;/label&gt;</span><br><span class="line">								&lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;col-sm-10&quot;</span>&gt;</span><br><span class="line">									&lt;input type=<span class="string">&quot;text&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;form-control&quot;</span> id=<span class="string">&quot;add_item_price&quot;</span> placeholder=<span class="string">&quot;原价&quot;</span> name=<span class="string">&quot;item_price&quot;</span>&gt;</span><br><span class="line">								&lt;/div&gt;</span><br><span class="line">							&lt;/div&gt;</span><br><span class="line">						&lt;/form&gt;  </span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                        &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;modal-footer&quot;</span>&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-default btn-sm&quot;</span> data-dismiss=<span class="string">&quot;modal&quot;</span>&gt;取消&lt;/button&gt;</span><br><span class="line">                            &lt;button type=<span class="string">&quot;button&quot;</span> <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;btn btn-primary btn-sm&quot;</span> onclick=<span class="string">&quot;addItem()&quot;</span>&gt;确认修改&lt;/button&gt;</span><br><span class="line">                        &lt;/div&gt;</span><br><span class="line">                    &lt;/div&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">            &lt;/div&gt;</span><br><span class="line">            </span><br><span class="line">            &lt;!-- main menu --&gt;</span><br><span class="line">            &lt;nav id=<span class="string">&quot;main_menu&quot;</span>&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;menu_wrapper&quot;</span>&gt;</span><br><span class="line">                    &lt;ul&gt;</span><br><span class="line">                        &lt;li <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;first_level&quot;</span>&gt;</span><br><span class="line">                            &lt;a href=<span class="string">&quot;javascript:void(0)&quot;</span>&gt;</span><br><span class="line">                                &lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;icon_document_alt first_level_icon&quot;</span>&gt;&lt;/span&gt;</span><br><span class="line">                                &lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;menu-title&quot;</span>&gt;游戏管理&lt;/span&gt;</span><br><span class="line">                            &lt;/a&gt;</span><br><span class="line">                            &lt;ul&gt;</span><br><span class="line">                                &lt;li <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;submenu-title&quot;</span>&gt;游戏管理&lt;/li&gt;</span><br><span class="line">                                &lt;!-- &lt;li&gt;&lt;a href=<span class="string">&quot;#&quot;</span> data-toggle=<span class="string">&quot;modal&quot;</span> data-target=<span class="string">&quot;#addLayer&quot;</span>&gt;商品添加&lt;/a&gt;&lt;/li&gt; --&gt;</span><br><span class="line">                                &lt;li&gt;&lt;a href=<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/item/list.do&quot;</span>&gt;游戏列表&lt;/a&gt;&lt;/li&gt;</span><br><span class="line">                            &lt;/ul&gt;</span><br><span class="line">                        &lt;/li&gt;</span><br><span class="line">                    &lt;/ul&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">                &lt;div <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;menu_toggle&quot;</span>&gt;</span><br><span class="line">                    &lt;span <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;icon_menu_toggle&quot;</span>&gt;</span><br><span class="line">                        &lt;i <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;arrow_carrot-2left toggle_left&quot;</span>&gt;&lt;/i&gt;</span><br><span class="line">                        &lt;i <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;arrow_carrot-2right toggle_right&quot;</span> style=<span class="string">&quot;display:none&quot;</span>&gt;&lt;/i&gt;</span><br><span class="line">                    &lt;/span&gt;</span><br><span class="line">                &lt;/div&gt;</span><br><span class="line">            &lt;/nav&gt;</span><br><span class="line">        &lt;/div&gt;</span><br><span class="line"></span><br><span class="line">        &lt;script type=<span class="string">&quot;text/javascript&quot;</span>&gt;</span><br><span class="line">	        $(function() &#123;</span><br><span class="line">	            <span class="comment">//footable</span></span><br><span class="line">	            yukon_footable.goodslist();</span><br><span class="line">	            <span class="comment">//datepicker</span></span><br><span class="line">	            yukon_datepicker.p_forms_extended();</span><br><span class="line">	        &#125;)</span><br><span class="line">	        </span><br><span class="line">	        <span class="comment">//修改弹框回显</span></span><br><span class="line">	       	<span class="function">function <span class="title">toEdit</span><span class="params">(id)</span> </span>&#123;</span><br><span class="line">	   			$.ajax(&#123;</span><br><span class="line">	   				type:<span class="string">&quot;post&quot;</span>,</span><br><span class="line">	   				url:<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/item/toEdit&quot;</span>,</span><br><span class="line">	   				data:&#123;<span class="string">&quot;id&quot;</span>:id&#125;,</span><br><span class="line">	   				success:function(data) &#123;</span><br><span class="line">	   					$(<span class="string">&quot;#edit_item_name&quot;</span>).val(data.item_name);</span><br><span class="line">	   					$(<span class="string">&quot;#edit_item_type&quot;</span>).val(data.item_type);</span><br><span class="line">	   					$(<span class="string">&quot;#edit_item_price&quot;</span>).val(data.item_price);</span><br><span class="line">	   				&#125;,</span><br><span class="line">	   				dataType:<span class="string">&quot;json&quot;</span></span><br><span class="line">	   			&#125;);</span><br><span class="line">	   		&#125;</span><br><span class="line">	        <span class="comment">//确认修改</span></span><br><span class="line">			<span class="function">function <span class="title">updateItem</span><span class="params">()</span> </span>&#123;</span><br><span class="line">				$.post(</span><br><span class="line">					<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/item/update.do&quot;</span>,</span><br><span class="line">					$(<span class="string">&quot;#edit_item_form&quot;</span>).serialize(),</span><br><span class="line">					function(data)&#123;</span><br><span class="line">						alert(<span class="string">&quot;游戏信息更新成功!&quot;</span>);</span><br><span class="line">						window.location.reload();</span><br><span class="line">				&#125;);</span><br><span class="line">			&#125;</span><br><span class="line">			</span><br><span class="line">	        <span class="comment">//确认删除</span></span><br><span class="line">			<span class="function">function <span class="title">deleteItem</span><span class="params">(id)</span> </span>&#123;</span><br><span class="line">				<span class="keyword">if</span>(confirm(<span class="string">&#x27;确实要删除该游戏吗?&#x27;</span>)) &#123;</span><br><span class="line">					$.post(</span><br><span class="line">						<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/item/delete.do&quot;</span>,</span><br><span class="line">						&#123;<span class="string">&quot;id&quot;</span>:id&#125;,</span><br><span class="line">						function(data)&#123;</span><br><span class="line">							window.location.reload();</span><br><span class="line">					&#125;);</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">			</span><br><span class="line">	        <span class="comment">//添加游戏</span></span><br><span class="line">			<span class="function">function <span class="title">addItem</span><span class="params">()</span> </span>&#123;</span><br><span class="line">				$.post(</span><br><span class="line">					<span class="string">&quot;$&#123;pageContext.request.contextPath &#125;/item/save.do&quot;</span>,</span><br><span class="line">					$(<span class="string">&quot;#add_item_form&quot;</span>).serialize(),</span><br><span class="line">					function(data)&#123;</span><br><span class="line">						alert(<span class="string">&quot;游戏添加成功!&quot;</span>);</span><br><span class="line">						window.location.reload();</span><br><span class="line">				&#125;);</span><br><span class="line">			&#125;</span><br><span class="line">		&lt;/script&gt;</span><br><span class="line">    &lt;/body&gt;</span><br><span class="line">&lt;/html&gt;</span><br></pre></td></tr></table></div></figure>




        <h1 id="SPRINGMVC-PROJECT-2"   >
          <a href="#SPRINGMVC-PROJECT-2" class="heading-link"><i class="fas fa-link"></i></a><a href="#SPRINGMVC-PROJECT-2" class="headerlink" title="SPRINGMVC-PROJECT-2"></a>SPRINGMVC-PROJECT-2</h1>
      
        <h2 id="新增登录拦截器与集成配置文件"   >
          <a href="#新增登录拦截器与集成配置文件" class="heading-link"><i class="fas fa-link"></i></a><a href="#新增登录拦截器与集成配置文件" class="headerlink" title="新增登录拦截器与集成配置文件"></a>新增登录拦截器与集成配置文件</h2>
      
        <h3 id="登录拦截器LoginIntercaptor-java"   >
          <a href="#登录拦截器LoginIntercaptor-java" class="heading-link"><i class="fas fa-link"></i></a><a href="#登录拦截器LoginIntercaptor-java" class="headerlink" title="登录拦截器LoginIntercaptor.java"></a>登录拦截器LoginIntercaptor.java</h3>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">LoginInterceptor</span> <span class="keyword">implements</span> <span class="title">HandlerInterceptor</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">preHandle</span><span class="params">(HttpServletRequest request, HttpServletResponse response, Object handler)</span></span></span><br><span class="line"><span class="function">			<span class="keyword">throws</span> Exception </span>&#123;</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//获取请求</span></span><br><span class="line">		String URI = request.getRequestURI();</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">if</span>(!URI.contains(<span class="string">&quot;login&quot;</span>)) &#123;</span><br><span class="line">			<span class="comment">//不是登录请求 拦截</span></span><br><span class="line">			Object user = request.getSession().getAttribute(<span class="string">&quot;user&quot;</span>);</span><br><span class="line">			</span><br><span class="line">			<span class="keyword">if</span>(user == <span class="keyword">null</span>) &#123;</span><br><span class="line">				<span class="comment">//没有登录 重定向到登录页面 / 请求</span></span><br><span class="line">				response.sendRedirect(request.getContextPath()+<span class="string">&quot;/login/login.do&quot;</span>);</span><br><span class="line">				<span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>


        <h3 id="集成配置文件-applicationContext-xml"   >
          <a href="#集成配置文件-applicationContext-xml" class="heading-link"><i class="fas fa-link"></i></a><a href="#集成配置文件-applicationContext-xml" class="headerlink" title="集成配置文件 applicationContext.xml"></a>集成配置文件 applicationContext.xml</h3>
      <figure class="highlight xml"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">beans</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://www.springframework.org/schema/beans&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:context</span>=<span class="string">&quot;http://www.springframework.org/schema/context&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:aop</span>=<span class="string">&quot;http://www.springframework.org/schema/aop&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:mvc</span>=<span class="string">&quot;http://www.springframework.org/schema/mvc&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xmlns:tx</span>=<span class="string">&quot;http://www.springframework.org/schema/tx&quot;</span></span></span><br><span class="line"><span class="tag">	<span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd</span></span></span><br><span class="line"><span class="string"><span class="tag">		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd&quot;</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 读取配置文件 数据库 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">context:property-placeholder</span> <span class="attr">location</span>=<span class="string">&quot;classpath:db.properties&quot;</span>/&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 配置数据源 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">name</span>=<span class="string">&quot;dataSource&quot;</span> <span class="attr">class</span>=<span class="string">&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;driverClass&quot;</span> <span class="attr">value</span>=<span class="string">&quot;$&#123;jdbc.driverClass&#125;&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;jdbcUrl&quot;</span> <span class="attr">value</span>=<span class="string">&quot;$&#123;jdbc.jdbcUrl&#125;&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;user&quot;</span> <span class="attr">value</span>=<span class="string">&quot;$&#123;jdbc.user&#125;&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">value</span>=<span class="string">&quot;$&#123;jdbc.password&#125;&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">	</span><br><span class="line">		<span class="comment">&lt;!-- 开启注解扫描 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">context:component-scan</span> <span class="attr">base-package</span>=<span class="string">&quot;com.sikiedu&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">context:component-scan</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 静态资源放行 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:resources</span> <span class="attr">location</span>=<span class="string">&quot;/css/&quot;</span> <span class="attr">mapping</span>=<span class="string">&quot;/css/**&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:resources</span> <span class="attr">location</span>=<span class="string">&quot;/fonts/&quot;</span> <span class="attr">mapping</span>=<span class="string">&quot;/fonts/**&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:resources</span> <span class="attr">location</span>=<span class="string">&quot;/js/&quot;</span> <span class="attr">mapping</span>=<span class="string">&quot;/js/**&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:resources</span> <span class="attr">location</span>=<span class="string">&quot;/picture/&quot;</span> <span class="attr">mapping</span>=<span class="string">&quot;/picture/**&quot;</span>/&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 开启注解驱动 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:annotation-driven</span>/&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 事务核心管理器 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">name</span>=<span class="string">&quot;transactionManager&quot;</span> <span class="attr">class</span>=<span class="string">&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;dataSource&quot;</span> <span class="attr">ref</span>=<span class="string">&quot;dataSource&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 开启注解事务 --&gt;</span>		</span><br><span class="line">		<span class="tag">&lt;<span class="name">tx:annotation-driven</span>/&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 配置视图解析器 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">class</span>=<span class="string">&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;prefix&quot;</span> <span class="attr">value</span>=<span class="string">&quot;/WEB-INF/jsp/&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;suffix&quot;</span> <span class="attr">value</span>=<span class="string">&quot;.jsp&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- 配置mybatis --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">name</span>=<span class="string">&quot;sqlSessionFactory&quot;</span> <span class="attr">class</span>=<span class="string">&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;dataSource&quot;</span> <span class="attr">ref</span>=<span class="string">&quot;dataSource&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;typeAliasesPackage&quot;</span> <span class="attr">value</span>=<span class="string">&quot;com.sikiedu.bean&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="comment">&lt;!-- mapper工厂 --&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">bean</span> <span class="attr">class</span>=<span class="string">&quot;org.mybatis.spring.mapper.MapperScannerConfigurer&quot;</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;basePackage&quot;</span> <span class="attr">value</span>=<span class="string">&quot;com.sikiedu.mapper&quot;</span>/&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">bean</span>&gt;</span></span><br><span class="line">		</span><br><span class="line">		<span class="tag">&lt;<span class="name">mvc:interceptors</span>&gt;</span></span><br><span class="line">			<span class="comment">&lt;!-- 登录验证拦截器 --&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">mvc:interceptor</span>&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**/*.css&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**/*.js&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**/*.png&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**/*.tff&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">&quot;/**/*.woff&quot;</span>/&gt;</span></span><br><span class="line">				<span class="tag">&lt;<span class="name">bean</span> <span class="attr">class</span>=<span class="string">&quot;com.sikiedu.interceptor.LoginInterceptor&quot;</span>/&gt;</span></span><br><span class="line">			<span class="tag">&lt;/<span class="name">mvc:interceptor</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">mvc:interceptors</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">beans</span>&gt;</span></span><br></pre></td></tr></table></div></figure></div><footer class="post-footer"><div class="post-ending ending"><div class="ending__text">------ 本文结束，感谢您的阅读 ------</div></div><div class="post-copyright copyright"><div class="copyright-author"><span class="copyright-author__name">本文作者: </span><span class="copyright-author__value"><a href="https://bruce-jj.gitee.io/blog">何水浪</a></span></div><div class="copyright-link"><span class="copyright-link__name">本文链接: </span><span class="copyright-link__value"><a href="https://bruce-jj.gitee.io/blog/2021/03/17/SpringMVC/">https://bruce-jj.gitee.io/blog/2021/03/17/SpringMVC/</a></span></div><div class="copyright-notice"><span class="copyright-notice__name">版权声明: </span><span class="copyright-notice__value">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" rel="external nofollow" target="_blank">BY-NC-SA</a> 许可协议。转载请注明出处！</span></div></div><div class="post-tags"><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="https://bruce-jj.gitee.io/blog/tags/SSM%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">SSM学习笔记</a></span></div><nav class="post-paginator paginator"><div class="paginator-prev"><a class="paginator-prev__link" href="/blog/2021/03/17/C-%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E5%9F%BA%E7%A1%80/"><span class="paginator-prev__icon"><i class="fas fa-angle-left"></i></span><span class="paginator-prev__text">C++面向对象基础</span></a></div><div class="paginator-next"><a class="paginator-next__link" href="/blog/2021/03/16/%E7%BF%BB%E8%AF%91%E4%BD%9C%E5%93%81-%E5%A4%A7%E6%95%B0%E6%8D%AE/"><span class="paginator-prev__text">翻译作品-大数据</span><span class="paginator-next__icon"><i class="fas fa-angle-right"></i></span></a></div></nav></footer></div></div><div class="comments" id="comments"><div id="valine-container"></div></div></div><div class="sidebar-wrap" id="sidebar-wrap"><aside class="sidebar" id="sidebar"><div class="sidebar-nav"><span class="sidebar-nav-toc current">文章目录</span><span class="sidebar-nav-ov">站点概览</span></div><section class="sidebar-toc"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#SpringMVC%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-number">1.</span> <span class="toc-text">
          SpringMVC是什么？</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E4%BD%BF%E7%94%A8SpringMVC%EF%BC%9F"><span class="toc-number">1.1.</span> <span class="toc-text">
          为什么要使用SpringMVC？</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%88%91%E8%83%BD%E4%BB%8E%E8%BF%99%E9%97%A8%E8%AF%BE%E4%B8%AD%E5%AD%A6%E5%88%B0%E4%BB%80%E4%B9%88%EF%BC%9F"><span class="toc-number">1.2.</span> <span class="toc-text">
          我能从这门课中学到什么？</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Part-1-SpringMVC%E5%85%A5%E9%97%A8%EF%BC%9A"><span class="toc-number">2.</span> <span class="toc-text">
          Part.1 SpringMVC入门：</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81SpringMVC%E7%AE%80%E8%A6%81%E5%A4%84%E7%90%86%E6%B5%81%E7%A8%8B%EF%BC%9A"><span class="toc-number">2.1.</span> <span class="toc-text">
          1、SpringMVC简要处理流程：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81HelloSpringMVC%EF%BC%9A%E6%90%AD%E5%BB%BASpringMVC-HelloWorld%E9%A1%B9%E7%9B%AE"><span class="toc-number">2.2.</span> <span class="toc-text">
          2、HelloSpringMVC：搭建SpringMVC HelloWorld项目</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81SpringMVC%E8%AF%A6%E7%BB%86%E5%A4%84%E7%90%86%E6%B5%81%E7%A8%8B%EF%BC%9A"><span class="toc-number">2.3.</span> <span class="toc-text">
          3、SpringMVC详细处理流程：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4%E3%80%81DispatcherServlet-properties%E5%86%85Bean%E5%AF%B9%E8%B1%A1%EF%BC%9A"><span class="toc-number">2.4.</span> <span class="toc-text">
          4、DispatcherServlet.properties内Bean对象：</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Part-2-SpringMVC-amp-Spring-amp-MyBatis%E6%95%B4%E5%90%88%EF%BC%9A"><span class="toc-number">3.</span> <span class="toc-text">
          Part.2 SpringMVC &amp; Spring &amp; MyBatis整合：</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E6%95%B4%E5%90%88ssm-3%E5%A4%A7%E6%A1%86%E6%9E%B6"><span class="toc-number">3.1.</span> <span class="toc-text">
          1、整合ssm 3大框架</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%87%86%E5%A4%87%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B"><span class="toc-number">3.2.</span> <span class="toc-text">
          2、准备测试用例</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Part-3-SpringMVC%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A%E4%B8%8E%E6%95%B0%E6%8D%AE%E4%BA%A4%E4%BA%92%EF%BC%9A"><span class="toc-number">4.</span> <span class="toc-text">
          Part.3 SpringMVC参数绑定与数据交互：</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E9%BB%98%E8%AE%A4%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A%EF%BC%9A%E9%80%9A%E8%BF%87id%E6%9F%A5%E8%AF%A2%E6%B8%B8%E6%88%8F%E4%BF%A1%E6%81%AF%EF%BC%8C%E5%B9%B6%E5%B0%86%E7%BB%93%E6%9E%9C%E6%98%BE%E7%A4%BA%E5%9C%A8%E9%A1%B5%E9%9D%A2%E4%B8%8A%EF%BC%9B"><span class="toc-number">4.1.</span> <span class="toc-text">
          1、默认参数绑定：通过id查询游戏信息，并将结果显示在页面上；</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%9F%BA%E6%9C%AC%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A%EF%BC%9A%E9%80%9A%E8%BF%87id%E5%88%A0%E9%99%A4%E6%B8%B8%E6%88%8F%E4%BF%A1%E6%81%AF%EF%BC%9B"><span class="toc-number">4.2.</span> <span class="toc-text">
          2、基本参数绑定：通过id删除游戏信息；</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81Bean%E5%AF%B9%E8%B1%A1%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A%EF%BC%9A%E6%B7%BB%E5%8A%A0%E6%B8%B8%E6%88%8F%EF%BC%9B"><span class="toc-number">4.3.</span> <span class="toc-text">
          3、Bean对象参数绑定：添加游戏；</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A4%8D%E6%9D%82%E7%B1%BB%E5%9E%8B%E5%8F%82%E6%95%B0%E7%BB%91%E5%AE%9A%EF%BC%9A"><span class="toc-number">4.4.</span> <span class="toc-text">
          复杂类型参数绑定：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Json%E6%95%B0%E6%8D%AE%E4%BA%A4%E4%BA%92%EF%BC%9A"><span class="toc-number">4.5.</span> <span class="toc-text">
          Json数据交互：</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Part-4-%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8%E4%B8%8E%E6%8B%A6%E6%88%AA%E5%99%A8"><span class="toc-number">5.</span> <span class="toc-text">
          Part.4 异常处理器与拦截器</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E9%80%9A%E8%BF%87%E5%AE%9E%E7%8E%B0HandlerExceptionResolver%E6%8E%A5%E5%8F%A3%E5%AE%8C%E6%88%90%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%EF%BC%9B"><span class="toc-number">5.1.</span> <span class="toc-text">
          1、通过实现HandlerExceptionResolver接口完成异常处理；</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E9%80%9A%E8%BF%87%E6%B3%A8%E8%A7%A3%E5%AE%8C%E6%88%90%E5%85%A8%E5%B1%80%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%EF%BC%9B"><span class="toc-number">5.2.</span> <span class="toc-text">
          2、通过注解完成全局异常处理；</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8B%A6%E6%88%AA%E5%99%A8Interceptor"><span class="toc-number">5.3.</span> <span class="toc-text">
          拦截器Interceptor</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1%E3%80%81SpringMvc%E4%B8%AD%E7%9A%84%E6%8B%A6%E6%88%AA%E5%99%A8%EF%BC%9A"><span class="toc-number">5.3.1.</span> <span class="toc-text">
          1、SpringMvc中的拦截器：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2%E3%80%81%E6%8B%A6%E6%88%AA%E5%99%A8%E7%9A%84%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B%E5%9B%BE%EF%BC%9A"><span class="toc-number">5.3.2.</span> <span class="toc-text">
          2、拦截器的执行流程图：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3%E3%80%81%E6%8B%A6%E6%88%AA%E5%99%A8%E7%9A%84%E6%89%A7%E8%A1%8C%E8%A7%84%E5%88%99%EF%BC%9B"><span class="toc-number">5.3.3.</span> <span class="toc-text">
          3、拦截器的执行规则；</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4%E3%80%81%E6%80%BB%E7%BB%93%E7%9A%84%E4%BA%94%E6%9D%A1%E6%8B%A6%E6%88%AA%E5%99%A8%E8%A7%84%E5%88%99%EF%BC%9B"><span class="toc-number">5.3.4.</span> <span class="toc-text">
          4、总结的五条拦截器规则；</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5%E3%80%81%E4%BD%BF%E7%94%A8%E6%8B%A6%E6%88%AA%E5%99%A8%E5%BC%80%E5%8F%91%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95%E6%A0%A1%E9%AA%8C%EF%BC%9B"><span class="toc-number">5.3.5.</span> <span class="toc-text">
          5、使用拦截器开发用户登录校验；</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6%E3%80%81%E4%BD%BF%E7%94%A8%E6%8B%A6%E6%88%AA%E5%99%A8%E6%90%AD%E9%85%8D%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8%E5%AE%8C%E6%88%90%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95%E6%97%B6%E7%9A%84%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%EF%BC%9B"><span class="toc-number">5.3.6.</span> <span class="toc-text">
          6、使用拦截器搭配异常处理器完成用户登录时的异常处理；</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7%E3%80%81%E9%9D%99%E6%80%81%E8%B5%84%E6%BA%90%E6%94%BE%E8%A1%8C%EF%BC%9B"><span class="toc-number">5.3.7.</span> <span class="toc-text">
          7、静态资源放行；</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8%E3%80%81RESTful%E9%A3%8E%E6%A0%BC%E5%BC%80%E5%8F%91%EF%BC%9A%E4%B8%80%E7%A7%8D%E4%BB%A5URL%E5%AE%9A%E4%BD%8D%E8%B5%84%E6%BA%90%E7%9A%84%E5%BC%80%E5%8F%91%E9%A3%8E%E6%A0%BC%E3%80%82%E4%BD%BF%E7%94%A8RESTful%E5%BC%80%E5%8F%91URL%E4%BC%9A%E5%8F%98%E5%BE%97%E4%B8%80%E7%9B%AE%E4%BA%86%E7%84%B6%EF%BC%8C%E6%9B%B4%E6%9C%89%E5%B1%82%E6%AC%A1%EF%BC%8C%E5%AE%83%E4%B8%8D%E6%98%AF%E6%A0%87%E5%87%86%E6%88%96%E8%80%85%E5%8D%8F%E8%AE%AE%EF%BC%9B"><span class="toc-number">5.3.8.</span> <span class="toc-text">
          8、RESTful风格开发：一种以URL定位资源的开发风格。使用RESTful开发URL会变得一目了然，更有层次，它不是标准或者协议；</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#SPRINGMVC-PROJECT-1"><span class="toc-number">6.</span> <span class="toc-text">
          SPRINGMVC-PROJECT-1</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%89%8D%E7%AB%AF%E8%AF%B7%E6%B1%82%E9%A1%B5%E9%9D%A2form-jsp"><span class="toc-number">6.1.</span> <span class="toc-text">
          前端请求页面form.jsp</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#WEB%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-web-xml"><span class="toc-number">6.2.</span> <span class="toc-text">
          WEB配置文件 web.xml</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SPRINGMVC%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-springmvc-xml"><span class="toc-number">6.3.</span> <span class="toc-text">
          SPRINGMVC配置文件 springmvc.xml</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#BEAN%E5%AF%B9%E8%B1%A1-ItemInfo-java"><span class="toc-number">6.4.</span> <span class="toc-text">
          BEAN对象 ItemInfo.java</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Controller%E5%B1%82-ItemController-java"><span class="toc-number">6.5.</span> <span class="toc-text">
          Controller层 ItemController.java</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E6%98%BE%E7%A4%BA%E9%A1%B5%E9%9D%A2-item-list-jsp"><span class="toc-number">6.6.</span> <span class="toc-text">
          数据显示页面 item_list.jsp</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#SPRINGMVC-PROJECT-2"><span class="toc-number">7.</span> <span class="toc-text">
          SPRINGMVC-PROJECT-2</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%B0%E5%A2%9E%E7%99%BB%E5%BD%95%E6%8B%A6%E6%88%AA%E5%99%A8%E4%B8%8E%E9%9B%86%E6%88%90%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">7.1.</span> <span class="toc-text">
          新增登录拦截器与集成配置文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%99%BB%E5%BD%95%E6%8B%A6%E6%88%AA%E5%99%A8LoginIntercaptor-java"><span class="toc-number">7.1.1.</span> <span class="toc-text">
          登录拦截器LoginIntercaptor.java</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%9B%86%E6%88%90%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-applicationContext-xml"><span class="toc-number">7.1.2.</span> <span class="toc-text">
          集成配置文件 applicationContext.xml</span></a></li></ol></li></ol></li></ol></section><!-- ov = overview--><section class="sidebar-ov hide"><div class="sidebar-ov-author"><div class="sidebar-ov-author__avatar"><img class="sidebar-ov-author__avatar_img" src="/blog/images/avatar.jpg" alt="avatar"></div><p class="sidebar-ov-author__text">C'est la vie</p></div><div class="sidebar-ov-state"><a class="sidebar-ov-state-item sidebar-ov-state-item--posts" href="/blog/archives/"><div class="sidebar-ov-state-item__count">48</div><div class="sidebar-ov-state-item__name">归档</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--categories" href="/blog/categories/"><div class="sidebar-ov-state-item__count">19</div><div class="sidebar-ov-state-item__name">分类</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--tags" href="/blog/tags/"><div class="sidebar-ov-state-item__count">20</div><div class="sidebar-ov-state-item__name">标签</div></a></div><div class="sidebar-ov-cc"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" target="_blank" rel="noopener" data-popover="知识共享许可协议" data-popover-pos="up"><img src="/blog/images/cc-by-nc-sa.svg"></a></div></section><div class="sidebar-reading"><div class="sidebar-reading-info"><span class="sidebar-reading-info__text">你已阅读了 </span><span class="sidebar-reading-info__num">0</span><span class="sidebar-reading-info__perc">%</span></div><div class="sidebar-reading-line"></div></div></aside></div><div class="clearfix"></div></div></main><footer class="footer" id="footer"><div class="footer-inner"><div><span>Copyright © 2021</span><span class="footer__icon"><i class="fas fa-heart"></i></span><span>何水浪</span></div><div><span>由 <a href="http://hexo.io/" title="Hexo" target="_blank" rel="noopener">Hexo</a> 强力驱动</span><span> v5.4.0</span><span class="footer__devider">|</span><span>主题 - <a href="https://github.com/liuyib/hexo-theme-stun/" title="Stun" target="_blank" rel="noopener">Stun</a></span><span> v2.6.2</span></div></div></footer><div class="loading-bar" id="loading-bar"><div class="loading-bar__progress"></div></div><div class="back2top" id="back2top"><span class="back2top__icon"><i class="fas fa-rocket"></i></span></div></div><div class="search-mask"></div><div class="search-popup"><span class="search-close"></span><div class="search-input"><input placeholder="搜索文章（支持多关键词，请用空格分隔）"></div><div class="search-results"></div></div><script src="https://cdn.jsdelivr.net/npm/jquery@v3.4.1/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.ui.min.js"></script><script>function initSearch() {
  var isXML = true;
  var search_path = 'search.json';

  if (!search_path) {
    search_path = 'search.xml';
  } else if (/json$/i.test(search_path)) {
    isXML = false;
  }

  var path = '/blog/' + search_path;
  $.ajax({
    url: path,
    dataType: isXML ? 'xml' : 'json',
    async: true,
    success: function (res) {
      var datas = isXML ? $('entry', res).map(function () {
        // 将 XML 转为 JSON
        return {
          title: $('title', this).text(),
          content: $('content', this).text(),
          url: $('url', this).text()
        };
      }).get() : res;
      var $input = $('.search-input input');
      var $result = $('.search-results');
      // 搜索对象（标题、内容）的权重，影响显示顺序
      var WEIGHT = { title: 100, content: 1 };
      var searchPost = function () {
        var searchText = $input.val().toLowerCase().trim();
        // 根据空白字符分隔关键字
        var keywords = searchText.split(/[\s]+/);
        // 搜索结果
        var matchPosts = [];

        // 有多个关键字时，将原文字整个保存下来
        if (keywords.length > 1) {
          keywords.push(searchText);
        }
        // 防止未输入字符时搜索
        if (searchText.length > 0) {
          datas.forEach(function (data) {
            var isMatch  = false;
            // 没有标题的文章使用预设的 i18n 变量代替
            var title = (data.title && data.title.trim()) || '[ 文章无标题 ]';
            var titleLower = title && title.toLowerCase();
            // 删除 HTML 标签 和 所有空白字符
            var content = data.content && data.content.replace(/<[^>]+>/g, '');
            var contentLower = content && content.toLowerCase();
            // 删除重复的 /
            var postURL = data.url && decodeURI(data.url).replace(/\/{2,}/g, '/');
            // 标题中匹配到的关键词
            var titleHitSlice = [];
            // 内容中匹配到的关键词
            var contentHitSlice = [];

            keywords.forEach(function (keyword) {
              /**
              * 获取匹配的关键词的索引
              * @param {String} keyword 要匹配的关键字
              * @param {String} text 原文字
              * @param {Boolean} caseSensitive 是否区分大小写
              * @param {Number} weight 匹配对象的权重。权重大的优先显示
              * @return {Array}
              */
              function getIndexByword (word, text, caseSensitive, weight) {
                if (!word || !text) {
                  return [];
                };

                var startIndex = 0; // 每次匹配的开始索引
                var index = -1;     // 匹配到的索引值
                var result = [];    // 匹配结果

                if (!caseSensitive) {
                  word = word.toLowerCase();
                  text = text.toLowerCase();
                }

                while((index = text.indexOf(word, startIndex)) !== -1) {
                  var hasMatch = false;
                  // 索引位置相同的关键词，保留长度较长的
                  titleHitSlice.forEach(function (hit) {
                    if (hit.index === index && hit.word.length < word.length) {
                      hit.word = word;
                      hasMatch = true;
                    }
                  });
                  startIndex = index + word.length;
                  !hasMatch && result.push({ index: index, word: word, weight: weight });
                }
                return result;
              }
              titleHitSlice = titleHitSlice.concat(getIndexByword(keyword, titleLower, false, WEIGHT.title));
              contentHitSlice = contentHitSlice.concat(getIndexByword(keyword, contentLower, false, WEIGHT.content));
            });

            var hitTitle = titleHitSlice.length;
            var hitContent = contentHitSlice.length;

            if (hitTitle > 0 || hitContent > 0) {
              isMatch = true;
            }
            if (isMatch) {
              ;[titleHitSlice, contentHitSlice].forEach(function (hit) {
                // 按照匹配文字的索引的递增顺序排序
                hit.sort(function (left, right) {
                  return left.index - right.index;
                });
              });
              /**
              * 给文本中匹配到的关键词添加标记，从而进行高亮显示
              * @param {String} text 原文本
              * @param {Array} hitSlice 匹配项的索引信息
              * @param {Number} start 开始索引
              * @param {Number} end 结束索引
              * @return {String}
              */
              function highlightKeyword (text, hitSlice, start, end) {
                if (!text || !hitSlice || !hitSlice.length) {
                  return;
                }

                var result = '';
                var startIndex = start;
                var endIndex = end;
                hitSlice.forEach(function (hit) {
                  if (hit.index < startIndex) {
                    return;
                  }

                  var hitWordEnd = hit.index + hit.word.length;
                  result += text.slice(startIndex, hit.index);
                  result += '<b>' + text.slice(hit.index, hitWordEnd) + '</b>';
                  startIndex = hitWordEnd;
                });
                result += text.slice(startIndex, endIndex);
                return result;
              }

              var postData = {};
              // 文章总的搜索权重
              var postWeight = titleHitSlice.length * WEIGHT.title + contentHitSlice.length * WEIGHT.content;
              // 标记匹配关键词后的标题
              var postTitle = highlightKeyword(title, titleHitSlice, 0, title.length) || title;
              // 标记匹配关键词后的内容
              var postContent;
              // 显示内容的长度
              var SHOW_WORD_LENGTH = 200;
              // 命中关键词前的字符显示长度
              var SHOW_WORD_FRONT_LENGTH = 20;
              var SHOW_WORD_END_LENGTH = SHOW_WORD_LENGTH - SHOW_WORD_FRONT_LENGTH;

              // 截取匹配的第一个字符，前后共 200 个字符来显示
              if (contentHitSlice.length > 0) {
                var firstIndex = contentHitSlice[0].index;
                var start = firstIndex > SHOW_WORD_FRONT_LENGTH ? firstIndex - SHOW_WORD_FRONT_LENGTH : 0;
                var end = firstIndex + SHOW_WORD_END_LENGTH;
                postContent = highlightKeyword(content, contentHitSlice, start, end);
              } else { // 未匹配到内容，直接截取前 200 个字符来显示
                postContent = content.slice(0, SHOW_WORD_LENGTH);
              }
              postData.title = postTitle;
              postData.content = postContent;
              postData.url = postURL;
              postData.weight = postWeight;
              matchPosts.push(postData);
            }
          });
        }

        var resultInnerHtml = '';
        if (matchPosts.length) {
          // 按权重递增的顺序排序，使权重大的优先显示
          matchPosts.sort(function (left, right) {
            return right.weight - left.weight;
          });
          resultInnerHtml += '<ul>';
          matchPosts.forEach(function (post) {
            resultInnerHtml += '<li><a class="search-results-title" href="' + post.url + '">';
            resultInnerHtml += post.title;
            resultInnerHtml += '</a><div class="search-results-content">';
            resultInnerHtml += post.content;
            resultInnerHtml += '</div></li>';
          });
          resultInnerHtml += '</ul>';
        } else {
          resultInnerHtml += '<div class="search-results-none"><i class="far fa-meh"></i></div>';
        }
        $result.html(resultInnerHtml);
      };
      $input.on('input', searchPost);
      $input.on('keyup', function (e) {
        if (e.keyCode === Stun.utils.codeToKeyCode('Enter')) {
          searchPost();
        }
      });
    }
  });
}

function closeSearch () {
  $('body').css({ overflow: 'auto' });
  $('.search-popup').css({ display: 'none' });
  $('.search-mask').css({ display: 'none' });
}

window.addEventListener('DOMContentLoaded', function () {
  Stun.utils.pjaxReloadLocalSearch = function () {
    $('.header-nav-search').on('click', function (e) {
      e.stopPropagation();
      $('body').css('overflow', 'hidden');
      $('.search-popup')
        .velocity('stop')
        .velocity('transition.expandIn', {
          duration: 300,
          complete: function () {
            $('.search-popup input').focus();
          }
        });
      $('.search-mask')
        .velocity('stop')
        .velocity('transition.fadeIn', {
          duration: 300
        });

      initSearch();
    });
    $('.search-mask, .search-close').on('click', function () {
      closeSearch();
    });
    $(document).on('keydown', function (e) {
      // Escape <=> 27
      if (e.keyCode === Stun.utils.codeToKeyCode('Escape')) {
        closeSearch();
      }
    });
  };

  Stun.utils.pjaxReloadLocalSearch();
}, false);

function safeOpenUrl(url) {
  var newTab = window.open();
  newTab.opener = null;
  newTab.location = url;
}

function extSearch(engine) {
  var engines = {
    google: 'https://www.google.com/search?q=',
    bing: 'https://cn.bing.com/search?q=',
    baidu: 'https://www.baidu.com/s?ie=UTF-8&wd=',
  };
  var host = window.location.host;
  var query = $('.search-input input').val().toLowerCase().trim();
  var uri = engines[engine] + query + ' site:' + host;

  if (query) {
    safeOpenUrl(uri);
  } else {
    Stun.utils.popAlert('warning', '请输入字符');
  }
}

var assistSearchList = window.CONFIG.assistSearch;

if (Array.isArray(assistSearchList)) {
  assistSearchList.forEach(function (name) {
    document.querySelector('.search-btns-item--' + name).addEventListener('click', function () {
      extSearch(name);
    }, false);
  });
}</script><script src="https://cdn.jsdelivr.net/npm/leancloud-storage@latest/dist/av-min.js"></script><script src="https://cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js"></script><script>function loadValine () {
  var GUEST_INFO = ['nick', 'mail', 'link'];
  var guest_info = 'nick';

  guest_info = guest_info.split(',').filter(function(item) {
    return GUEST_INFO.indexOf(item) > -1;
  });
  new Valine({
    el: '#valine-container',
    appId: 'fJ4fFnieffDVKy4Jkn16aHdO-gzGzoHsz',
    appKey: 'qfVo2CUC2pJ3udFzLFnd0GBM',
    notify: true,
    verify: true,
    placeholder: '说点啥再走呗~爱你',
    avatar: 'mp',
    meta: guest_info,
    pageSize: '10' || 10,
    visitor: false,
    recordIP: false,
    lang: '' || 'zh-cn',
    path: window.location.pathname
  });
}

if (false) {
  loadValine();
} else {
  window.addEventListener('DOMContentLoaded', loadValine, false);
}</script><script src="/blog/js/utils.js?v=2.6.2"></script><script src="/blog/js/stun-boot.js?v=2.6.2"></script><script src="/blog/js/scroll.js?v=2.6.2"></script><script src="/blog/js/header.js?v=2.6.2"></script><script src="/blog/js/sidebar.js?v=2.6.2"></script><script type="application/json" src="/blog/search.json"></script></body></html>